<script setup>
import { ref } from 'vue'
import { Edit, Delete } from '@element-plus/icons-vue'
// 默认数据
const defaultForm = ref([
  { column: '政治', num: '423515', sum: '2342', time: '2023-12-05 16:29:09' },
  { column: '经济', num: '4512516', sum: '2342', time: '2023-12-05 16:29:09' },
  { column: '科技', num: '34524', sum: '2342', time: '2023-12-05 16:29:09' },
  { column: '社会', num: '32456', sum: '2342', time: '2023-12-05 16:29:09' },
  { column: '娱乐', num: '24532', sum: '2342', time: '2023-12-05 16:29:09' },
  { column: '文化', num: '12341', sum: '2342', time: '2023-12-05 16:29:09' },
  { column: '健康', num: '2345', sum: '2342', time: '2023-12-05 16:29:09' },
  { column: '科学', num: '3456', sum: '2342', time: '2023-12-05 16:29:09' },
  { column: '体育', num: '5678', sum: '2342', time: '2023-12-05 16:29:09' },
  { column: '教育', num: '3456', sum: '2342', time: '2023-12-05 16:29:09' },
  { column: '国际', num: '1234', sum: '2342', time: '2023-12-05 16:29:09' },
  { column: '环境', num: '5432', sum: '2342', time: '2023-12-05 16:29:09' },
  { column: '战略军事', num: '94925', sum: '2342', time: '2023-12-05 16:29:09' },
  { column: '人文历史', num: '43734', sum: '2342', time: '2023-12-05 16:29:09' }
])
// 准备数据
const tableData = ref({ ...defaultForm })
console.log(tableData.value)
</script>

<template>
  <AdminNewsPage title="新闻栏目">
    <template #operate>
      <el-button type="primary">修改栏目</el-button>
    </template>
    <el-table v-loading="loading" :data="defaultForm" style="width: 100%">
      <el-table-column type="index" label="序号" width="100"></el-table-column>
      <el-table-column prop="column" label="栏目类别"></el-table-column>
      <el-table-column prop="num" label="栏目新闻数"></el-table-column>
      <el-table-column prop="sum" label="栏目总浏览量"></el-table-column>
      <el-table-column prop="time" label="最近发布时间"></el-table-column>
      <el-table-column label="操作" width="150">
        <!-- row 就是 channelList 的一项， $index 下标 -->
        <template #default="{ row, $index }">
          <el-button
            :icon="Edit"
            circle
            plain
            type="primary"
            @click="onEditChannel(row, $index)"
          ></el-button>
          <el-button
            :icon="Delete"
            circle
            plain
            type="danger"
            @click="onDelChannel(row, $index)"
          ></el-button>
        </template>
      </el-table-column>

      <template #empty>
        <el-empty description="没有数据"></el-empty>
      </template>
    </el-table>

    <channel-edit ref="dialog" @success="onSuccess"></channel-edit>
  </AdminNewsPage>
</template>

<style lang="scss" scoped></style>
